import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { UploadTypeEnum } from '/@/components/Form/src/jeecg/components/JUpload';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns : BasicColumn[] = [
	{
		title: '加入时间',
		align: "center",
		dataIndex: 'createtimeString'
	},
	{
		title: '真实姓名',
		align: "center",
		dataIndex: 'extInfors',
		customRender: ({ text, column }) => {
			if (text == null || text == {}) {
				return ''
			}
			if (text.indexOf("realName") > -1) {
				let remark = JSON.parse(text).realName
				if (!remark) {
					remark = JSON.parse((JSON.parse(text))).realName
				}
				return remark;
			} else {
				return ""
			}
		},

	},
	{
		title: '邀请人',
		align: "center",
		dataIndex: 'inviteId_dictText'
	},
	{
		title: '昵称',
		align: "center",
		dataIndex: 'nickname'
	},
	{
		title: '手机号',
		align: "center",
		dataIndex: 'phone'
	},
	{
		title: '头像',
		align: "center",
		dataIndex: 'cover',
		customRender: render.renderImage,
	},

	{
		title: '城市',
		align: "center",
		dataIndex: 'cityId_dictText',
	},
	{
		title: '租户',
		align: "center",
		dataIndex: 'tenantId_dictText'
	},
	{
		title: '学校',
		align: "center",
		dataIndex: 'schoolId_dictText'
	},
	/* {
		title: 'vip等级',
		align: "center",
		sorter: true,
		dataIndex: 'vip_dictText'
	},
	{
		title: '累计消费金额',
		align: "center",
		sorter: true,
		dataIndex: 'totalAmount'
	},
	{
		title: '累计消费次数',
		align: "center",
		sorter: true,
		dataIndex: 'totalNum'
	}, */
	{
		title: '标签',
		align: "center",
		dataIndex: 'tagsId_dictText'
	},
	{
		title: '备注',
		align: "center",
		dataIndex: 'extInfors',
		customRender: ({ text, column }) => {
			if (text == null || text == {}) {
				return ''
			}
			if (text.indexOf("remark") > -1) {
				let remark = JSON.parse(text).remark
				if (!remark) {
					remark = JSON.parse((JSON.parse(text))).remark
				}
				return remark;
			} else {
				return ""
			}
		},
	},

	{
		title: '性别',
		align: "center",
		dataIndex: 'sex_dictText'
	},
	{
		title: '年龄',
		align: "center",
		sorter: true,
		dataIndex: 'age'
	},
	{
		title: '身份证',
		align: "center",
		dataIndex: 'idcard'
	},
];

//子表列表数据
export const coupleUserStrokeBindingRecordColumns : BasicColumn[] = [
	{
		title: '行程id',
		align: "center",
		dataIndex: 'carpoolBus_dictText'
	},
	{
		title: '绑定状态',
		align: "center",
		dataIndex: 'bindingStatus_dictText'
	},
	{
		title: '评语',
		align: "center",
		dataIndex: 'comment'
	},
];
//子表表单数据
export const coupleUserStrokeBindingRecordFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '行程id',
		field: 'carpoolBus',
		component: 'JSearchSelect',
		componentProps: {
			dict: "couple_activity_carpool_bus,carpool_number,id"
		},
	},
	{
		label: '绑定状态',
		field: 'bindingStatus',
		component: 'JSearchSelect',
		componentProps: {
			dict: "stroke_binding_status"
		},
	},
	{
		label: '评语',
		field: 'comment',
		component: 'InputTextArea',
	},
];
//查询数据
export const searchFormSchema : FormSchema[] = [
	{
		label: "昵称",
		field: "nickName",
		component: 'Input',
		//colProps: {span: 6},
	},
	{
		label: "手机号",
		field: "phone",
		component: 'Input',
		//colProps: {span: 6},
	},
	{
		label: "真实姓名",
		field: "userName",
		component: 'Input',
		//colProps: {span: 6},
	},
	/* {
		label: "城市",
		field: "cityId",
		component: 'JCategorySelect',
		componentProps: {
			pcode: "",//back和事件未添加，暂时有问题
		},
		//colProps: {span: 6},
	},
	{
		label: "租户",
		field: "tenantId",
		component: 'JSearchSelect',
		componentProps: {
			dict: "sys_tenant,name,id"
		},
		//colProps: {span: 6},
	},
	{
		label: "学校",
		field: "schoolId",
		component: 'JSearchSelect',
		componentProps: {
			dict: "couple_school,title,id"
		},
		//colProps: {span: 6},
	},
	{
		label: "vip等级",
		field: "vip",
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "sys_category,name,id,pid='1724609757009944577'"
		},
		//colProps: {span: 6},
	},
	{
		label: "标签",
		field: "tags",
		component: 'JSelectMultiple',
		componentProps: {
			dictCode: "sys_category,name,id,pid='1726774800472363009'",
			triggerChange: true
		},
		//colProps: {span: 6},
	}, */

	{
		label: "性别",
		field: "sex",
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "sex_new"
		},
		//colProps: {span: 6},
	},

];

export const updateRoleFrom : FormSchema[] = [
	{
		label: 'userId',
		field: 'userId',
		component: 'Input',
		show: false
	},
	{
		label: '角色',
		field: 'roleCode',
		component: 'JSelectMultiple',
		componentProps: {
			dictCode: "user_role"
		},
	},
]

export const updateInviteIdFrom : FormSchema[] = [
	{
		label: 'id',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '选择上级',
		field: 'inviteId',
		component: 'JSearchSelect',
		componentProps: {
			dict: "BS_UserLayout_AgentInfors,realName,id,stats='Active'"
		},
	},
]

//选择标签
export const updateTagsFrom : FormSchema[] = [
	{
		label: 'userId',
		field: 'phone',
		component: 'Input',
		show: false
	},
	{
		label: '标签',
		field: 'tagsId',
		component: 'JSelectMultiple',
		componentProps: {
			dictCode: "sys_category,name,id,pid='1726774800472363009'"
		},
	},
]



//选择学校
export const updateSchoolFrom : FormSchema[] = [
	{
		label: 'userId',
		field: 'phone',
		component: 'Input',
		show: false
	},
	{
		label: '学校',
		field: 'schoolId',
		component: 'JSearchSelect',
		componentProps: {
			dict: "couple_school,title,id"
		},
	},

]
//选择城市
export const updateCityFrom : FormSchema[] = [
	{
		label: 'userId',
		field: 'phone',
		component: 'Input',
		show: false
	},
	{
		label: '城市',
		field: 'cityId',
		component: 'JTreeDict',
		componentProps: { async: true, parentCode: 'A02' },
	},

]




//表单数据
export const formSchema : FormSchema[] = [
	{
		label: '手机号',
		field: 'phone',
		component: 'Input',
		required: true
	},
	{
		label: '昵称',
		field: 'nickname',
		component: 'Input',
		required: true
	},
	{
		label: '身份证号',
		field: 'idcard',
		component: 'Input',
		required: true
	},
	{
		label: '真实姓名',
		field: 'realname',
		component: 'Input',
		required: true
	},
	{
		label: '头像',
		field: 'cover',
		component: 'JUpload',
		helpMessage: '最多上传1张图片',
		componentProps: {
			fileType: UploadTypeEnum.image,
			maxCount: 1,
		},
		required: true
	},
	{
		label: '账号状态',
		field: 'stats',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'user_status_new'
		},
		required: true
	},
	/* {
		label: '角色',
		field: 'roleCode',
		component: 'JSelectMultiple',
		componentProps: {
			dictCode: "user_role"
		},
		required: true
	}, */
	{
		label: '城市',
		field: 'cityId',
		component: 'JTreeDict',
		componentProps: { async: true, parentCode: 'A02' },
	},
	{
		label: '学校',
		field: 'schoolId',
		component: 'JSearchSelect',
		componentProps: {
			dict: "couple_school,title,id"
		},
	},
	{
		label: '标签',
		field: 'tagsId',
		component: 'JSelectMultiple',
		componentProps: {
			dictCode: "sys_category,name,id,pid='1726774800472363009'"
		},
	},
	{
		label: '备注',
		field: 'remark',
		component: 'InputTextArea',//TODO 注意string转换问题
	},

	{
		label: '性别',
		field: 'sex',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "sex_new"
		},
	},
	/* 	{
			label: '年龄',
			field: 'age',
			component: 'InputNumber',
		},
		{
			label: '身份',
			field: 'identity',
			component: 'JDictSelectTag',
			componentProps: {
				dictCode: 'new_user_identity'
			},
		}, */
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '',
		field: 'tenantId',
		component: 'Input',
		show: false
	},
];

//子表列表数据
export const coupleLeaderContractColumns : BasicColumn[] = [
	{
		title: '签订时间',
		align: "center",
		dataIndex: 'createTime'
	},
	{
		title: '签字',
		align: "center",
		dataIndex: 'signature',
		customRender: render.renderImage,
	},
	{
		title: '合同',
		align: "center",
		dataIndex: 'contractId_dictText'
	},
	{
		title: '签订的合同',
		align: "center",
		dataIndex: 'img',
		customRender: render.renderImage,
	},
	{
		title: '领队',
		align: "center",
		dataIndex: 'leaderId_dictText'
	},
	{
		title: '租户',
		align: "center",
		dataIndex: 'tenantId_dictText'
	},
];
//子表表单数据
export const coupleLeaderContractFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
];
//子表列表数据
export const coupleUserFinanceColumns : BasicColumn[] = [
	{
		title: '可提现余额',
		align: "center",
		dataIndex: 'balance'
	},
	/* 	{
			title: '总佣金',
			align: "center",
			dataIndex: 'grossCommission'
		},
		{
			title: '已提现佣金',
			align: "center",
			dataIndex: 'yiCommission'
		},
		{
			title: '未提现佣金',
			align: "center",
			dataIndex: 'weiCommission'
		}, */
	{
		title: '总使用优惠券抵扣金额',
		align: "center",
		dataIndex: 'totalDiscountCoupon'
	},
	{
		title: '总支付金额',
		align: "center",
		dataIndex: 'totalSale'
	},
];
//子表表单数据
export const coupleUserFinanceFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
];
//子表列表数据
export const coupleUserDiscountCouponColumns : BasicColumn[] = [
	{
		title: '金额',
		align: "center",
		dataIndex: 'price'
	},
	{
		title: '过期时间',
		align: "center",
		dataIndex: 'expirationTime'
	},
	/* {
		title: '券',
		align: "center",
		dataIndex: 'couponId_dictText'
	}, */
	{
		title: '使用状态',
		align: "center",
		dataIndex: 'useStatus_dictText'
	},
	{
		title: '租户',
		align: "center",
		dataIndex: 'tenantId_dictText'
	},
];
//子表表单数据
export const couponFrom : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '券',
		field: 'couponId',
		component: 'JSearchSelect',
		componentProps: {
			dict: "couple_discount_coupon,title,id"
		},
	},
];

export const coupleUserDiscountCouponFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '金额',
		field: 'price',
		component: 'Input',
	},
	{
		label: '过期时间',
		field: 'expirationTime',
		component: 'DatePicker',
		componentProps: {
			showTime: true,
			valueFormat: 'YYYY-MM-DD HH:mm:ss'
		},
	},
];


//子表列表数据
export const coupleAccountChangeRecordColumns : BasicColumn[] = [
	{
		title: '时间',
		align: "center",
		dataIndex: 'createTime'
	},
	/* 	{
			title: '用户',
			align: "center",
			dataIndex: 'userId_dictText'
		}, */
	{
		title: '账变类别',
		align: "center",
		dataIndex: 'recordType',
		customRender: ({ text }) => {
			if (text == 1) return '成团失败退款'
			if (text == 2) return '游客取消行程申请退款'
			if (text == 3) return '给游客优惠退款'
			if (text == 4) return '游客报名支付'
			if (text == 5) return '代理佣金扣除'
			if (text == 6) return '佣金发放'
			if (text == 7) return '申请提现'
			if (text == 8) return '发布订单'
			if (text == 9) return '分销佣金'
			if (text == 10) return '推广佣金'
		}
	},
	{
		title: '变化金额',
		align: "center",
		sorter: true,
		dataIndex: 'price'
	},
	{
		title: '账变前',
		align: "center",
		sorter: true,
		dataIndex: 'changeFront'
	},
	{
		title: '变化后',
		align: "center",
		sorter: true,
		dataIndex: 'changBack'
	},
	{
		title: '变化状态',
		align: "center",
		dataIndex: 'changeStatus',
		customRender: ({ text }) => {
			if (text == 4) return '待结算佣金'
			if (text == 1) return '审核通过'
			if (text == -1) return '审核不通过'
			if (text == 0) return '审核中'
			if (text == 2) return '成功'
			if (text == 3) return '失败'
			if (text == 'PayFail') return '支付失败'
			if (text == 'Payed') return '支付成功'
			if (text == 6) return '待支付'
			if (text == 5) return '已结算佣金'
		}
	},
	{
		title: '租户',
		align: "center",
		dataIndex: 'tenantId_dictText'
	},
];
//子表表单数据
export const coupleAccountChangeRecordFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
];